﻿@model PagedList<ADZ_BrandMaster>
@{
    ViewBag.Title = "品牌列表";
    Layout = "~/Views/Shared/_ContentLayout.cshtml";

    BrandListQueryModel paramModel = new BrandListQueryModel();
    if (ViewBag.paramModel != null)
    {
        paramModel = (BrandListQueryModel)ViewBag.paramModel;
    }
    ADZ_MasterEntities dbcontext = new ADZ_MasterEntities();
    Dictionary<string, string> dc = new Dictionary<string, string>();
}

<form id="S_Form" class="form-inline definewidth m20" action="@Url.Action("brandlist", "brand")" method="get">
    <div class="form_query">
        <div>
            品牌名称：
            <input type="text" name="brand_name" id="brand_name" class="abc input-default" placeholder="" value="@paramModel.brand_name">&nbsp;
        </div>
        <div>
            品牌英文名称：
            <input type="text" name="brand_name_en" id="brand_name_en" class="abc input-default" placeholder="" value="@paramModel.brand_name_en">&nbsp;
        </div>
        <div>
            是否显示：
            <select id="is_show" name="is_show">
                <option value="-10" @(paramModel.is_show == -10 ? "selected" : "")>全部</option>
                @{
                    dc = new Dictionary<string, string>();
                    dc.Add("0", "不显示");
                    dc.Add("1", "显示");
                }
                @HtmlPagerHelper.ShowSelectOpton(dc, paramModel.is_show.ToString());
            </select>&nbsp;
        </div>
        <div>
            @{Html.RenderPartial(Url.Content("~/Views/Common/PageSize.cshtml"), paramModel);}
        </div><div>
            <button type="submit" class="btn btn-primary">查询</button>&nbsp;&nbsp;
            <button type="button" class="btn btn-success" id="btnadd" onclick="document.location='@Url.Action("add","brand")'">新增</button>
        </div>
    </div>
</form>
<table class="table table-bordered table-hover definewidth m10">
    <thead>
        <tr>
            <th>LOGO</th>
            <th>编号</th>
            <th>品牌名称</th>
            <th>品牌英文名称</th>
            <th>品牌说明</th>
            <th>是否显示</th>
            <th>创建时间</th>
            <th>操作</th>
        </tr>
    </thead>
    @if (Model != null && Model.Count != 0)
    {
        int index = 0;
        foreach (var m in Model)
        {
            index++;
            <tr class="@HtmlPagerHelper.TrClass(index)">
                <td style="text-align:center;vertical-align:middle;"><img src="@ImageFileBiz.GetImg(m.logo_img_url,"small")" class="height30" /></td>
                <td>@m.brand_id</td>
                <td>@m.brand_name</td>
                <td>@m.brand_name_en</td>
                <td title="@m.brand_content"><div class="longcontent">@m.brand_content</div></td>
                <td>
                    @switch (m.is_show)
                    {
                        case 1:
                            @:<div class="green">显示</div>
                            break;
                        case 0:
                            @:<div class="red">不显示</div>
                            break;
                    }
                </td>
                <td>@m.create_time.ToString(1)</td>
                <td>
                    <a href="@Url.Action("add", "brand", new { id = m.brand_id})">编辑</a>
                    <a href="javascript:void(0);" onclick="toDel(@m.brand_id)">删除</a>
                </td>
            </tr>
        }
    }
</table>
<div class="inline pull-left total">
    总行数：@ViewData["AllCount"]
</div>
<div class="inline pull-right page">
    @if (Model != null)
    {
        @Html.Pager(Model, HtmlPagerHelper.BasePagerOption)
    }
</div>
<script>
    reloadHandler = function () {
        window.location.reload();
    }

    function toDel(id) {
        BUI.Message.Show({
            title: '提示',
            msg: '确定要删除该品牌吗?',
            icon: 'question',
            buttons: [
                {
                    text: '确定',
                    elCls: 'button button-primary',
                    handler: function () {
                        url = "@Url.Action("ToDel", "brand")";
                                parameter = { id: id };
                      $.post(url, parameter, function (result) {
                                    ShowActionResult(result, reloadHandler);
                                });
                                this.close();
                            }
                        },
              {
                            text: '取消',
                  elCls: 'button',
                  handler: function () {
                                this.close();
                            }
              }

            ]
        });
    }
</script>

